<?php

namespace app\models;

use Yii;
use app\models\User;

/**
 * This is the model class for table "{{%tbl_net}}".
 *
 * @property integer $id
 * @property integer $status
 * @property integer $user_id
 * @property integer $opponent_id
 * @property integer $img
 */
class Net extends \yii\db\ActiveRecord
{
    const STATUS_WAIT = 10000;
    const STATUS_BATTLE = 10001;
    const STATUS_DIE = 10002;

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%tbl_net}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['status', 'user_id'], 'required'],
            [['status', 'user_id', 'opponent_id'], 'integer']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('Net', 'ID'),
            'status' => Yii::t('Net', 'Status'),
            'user_id' => Yii::t('Net', 'User ID'),
            'opponent_id' => Yii::t('Net', 'Opponent ID'),
            'img' => Yii::t('Net', 'Img'),
        ];
    }
    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUser()
    {
        return $this->hasOne(User::className(), ['user_id' => 'user_id']);
    }

}
